package pers.ree.demo.option;

import org.junit.Test;

import java.util.Optional;

public class OptionalDemo {

    @Test
    public void ofNull(){
        User user = null;

        System.out.println(Optional.ofNullable(user).filter(u->!"".equals(u.getUserName())));
    }

    class User {

        private String userName;


        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }
    }
}
